package com.nexus.all.constants;

import com.nexus.bean.utils.StringUtils;

import java.util.Objects;

/**
 * @author zxt
 */
public class RedisKeyNexus {

    private static final String NEXUS = "nexus:";

    public static final String ALL_USER_INFO = "all:user:info";

    /**
     * 获取手机验证码
     *
     * @param mobile
     * @return
     */
    public static String getMobileCaptchaKey(String mobile) {
        StringBuilder sbBuilder = new StringBuilder(80);
        sbBuilder.append(NEXUS);
        sbBuilder.append("mobile:");
        sbBuilder.append("captcha:");
        sbBuilder.append(mobile);
        return sbBuilder.toString();
    }



    /**
     * 获取用户公众号选择
     *
     * @param wxOpenId
     * @return
     */
    public static String getAiUserChoose(String wxOpenId) {
        StringBuilder sbBuilder = new StringBuilder(80);
        sbBuilder.append(NEXUS);
        sbBuilder.append("ai:userChoose:");
        sbBuilder.append("wxOpenId:");
        sbBuilder.append(wxOpenId);
        return sbBuilder.toString();
    }

    public static String getLock(String key, Object dataId) {
        if (StringUtils.isEmpty(key)) {
            return "";
        }
        StringBuilder builder = new StringBuilder(80);
        builder.append(NEXUS);
        builder.append("lock:key:");
        builder.append(key);
        if (Objects.nonNull(dataId)) {
            builder.append("dataId:");
            builder.append(dataId);
        }
        return builder.toString();
    }
}
